<template>
	<div class="article-lists">
		<el-card class="!border-none" shadow="never">
			<!-- <el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true">
				<el-form-item label="审核状态">
					<el-select class="w-[280px]" v-model="queryParams.state">
						<el-option label="全部" value />
						<el-option label="已审核" :value="1" />
						<el-option label="未审核" :value="0" />
					</el-select>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="resetPage">查询</el-button>
					<el-button @click="resetParams">重置</el-button>
				</el-form-item>
			</el-form> -->
		</el-card>
		<el-card class="!border-none mt-4" shadow="never">
			<!-- <div>
			  <router-link
			    v-perms="['enterprise.enterprise']"
			    :to="{
			                  path: getRoutePath('enterprise.enterprise')
			              }"
			  >
			    <el-button class="mb-4" type="primary">
			      <template #icon>
			        <icon name="el-icon-Plus" />
			      </template>
			      新增企业
			    </el-button>
			  </router-link>
			</div> -->
	<!-- 		<div>
				<router-link v-perms="['article.article/add', 'article.article/add:edit']" :to="{
                        path: getRoutePath('article.article/add:edit')
                    }">
					<el-button type="primary" class="mb-4">
						<template #icon>
							<icon name="el-icon-Plus" />
						</template>
						发布企业采购信息
					</el-button>
				</router-link>
			</div> -->
			<el-table Checkbox="true" type="selection" size="large" v-loading="pager.loading" :data="pager.lists">
				<el-table-column label="ID" prop="id" min-width="80" />
				<el-table-column label="昵称" prop="nickname" min-width="100" />
				<el-table-column label="联系人" prop="pople" min-width="100" />
				<el-table-column label="联系电话" prop="mobile" min-width="100" />
				<!-- <el-table-column label="联系地址" prop="address" min-width="170" /> -->
				<!-- <el-table-column label="申请类型" prop="leixing" min-width="120" /> -->
			<!-- 	<el-table-column label="申请类型" min-width="100">
					<template #default="{ row }">
						<div v-if="row.leixing==1">企业类型</div>
						<div v-if="row.leixing==2">商户类型</div>
					</template>
				</el-table-column> -->
				<!-- <el-table-column label="企业商标" min-width="100">
					<template #default="{ row }">
						<image-contain v-if="row.qyimg" :src="row.qyimg" :width="60" :height="45"
							:preview-src-list="[row.qyimg]" preview-teleported fit="contain" />
					</template>
				</el-table-column> -->
			<!-- 	<el-table-column label="门店照片" min-width="100">
					<template #default="{ row }">
						<image-contain v-if="row.storeimg" :src="row.storeimg" :width="60" :height="45"
							:preview-src-list="[row.storeimg]" preview-teleported fit="contain" />
					</template>
				</el-table-column> -->
				<el-table-column label="仓库照片" min-width="100">
					<template #default="{ row }">
						<image-contain v-if="row.zhaop" :src="row.zhaop" :width="60" :height="45"
							:preview-src-list="[row.zhaop]" preview-teleported fit="contain" />
					</template>
				</el-table-column>
				<!-- <el-table-column label="企业详情" prop="qyxaingqing" min-width="100" /> -->
				<!--   <el-table-column
                    label="标题"
                    prop="title"
                    min-width="160"
                    show-tooltip-when-overflow
                /> -->
				<!-- <el-table-column label="信息分类" prop="cate_name" min-width="100" /> -->
				<!-- <el-table-column label="作者" prop="author" min-width="120" /> -->
				<!-- <el-table-column label="浏览量" prop="click" min-width="100" /> -->
			<!-- 	<el-table-column label="审核状态" min-width="100">
				  <template #default="{ row }">
                        <el-switch
                            v-perms="['article.qualifications/edit']"
                            v-model="row.state"
                            :active-value="1"
                            :inactive-value="0"
                            @change="changeStatus($event, row.id)"
                        />
                    </template>
                </el-table-column> -->
				<!-- <el-table-column label="排序" prop="sort" min-width="100" /> -->
				<!-- <el-table-column label="发布时间" prop="creat'e_time" min-width="120" /> -->
				<!-- <el-table-column label="操作" width="120" fixed="right">
					<template #default="{ row }">
						<el-button v-perms="['article.qualifications/delete']" type="danger" link
							@click="handleDelete(row.id)">
							删除
						</el-button>
					</template>
				</el-table-column> -->
			</el-table>
			<div class="flex justify-end mt-4">
				<pagination v-model="pager" @change="getLists" />
			</div>
		</el-card>
	</div>
</template>
<script lang="ts" setup name="qualificationslist">
	import { zizhiDelete, articleStatus, articleCateAll, qualificationslist,zizhhiStatus } from '@/api/article'
	import { useDictOptions } from '@/hooks/useDictOptions'
	import { usePaging } from '@/hooks/usePaging'
	import { getRoutePath } from '@/router'
	import feedback from '@/utils/feedback'
	import { getUserList ,delUserList } from '@/api/consumer'
	const queryParams = reactive({
		// title: '',
		// cid: '',
		// is_show: '',
		state:'1'
	})

	const { pager, getLists, resetPage, resetParams } = usePaging({
		fetchFun: getUserList,
		params: queryParams
	})

	const { optionsData } = useDictOptions<{
		article_cate : any[]
	}>({
		article_cate: {
			api: articleCateAll
		}
	})

	const changeStatus = async (is_show : any, id : number) => {
		try {
			await zizhhiStatus({ id, is_show })
			getLists()
		} catch (error) {
			getLists()
		}
	}

	const handleDelete = async (id : number) => {
		await feedback.confirm('确定要删除？')
		await zizhiDelete({ id })
		getLists()
	}

	onActivated(() => {
		getLists()
	})

	getLists()
</script>